package com.example.myactspringboot.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @Create 2023-09-23 16:05
 * @Description
 */
public class R2 {

    private Boolean success;

    private Integer code;

    private String message;

    private Object data;
//    private List list = new ArrayList();

    //把构造方法私有
    private R2() {}

    //成功静态方法
    public static R2 ok() {
        R2 r = new R2();
        r.setSuccess(true);
        r.setCode(20000);
        r.setMessage("success");
        return r;
    }

    //失败静态方法
    public static R2 error() {
        R2 r = new R2();
        r.setSuccess(false);
        r.setCode(20001);
        r.setMessage("error");
        return r;
    }

    public R2 success(Boolean success){
        this.setSuccess(success);
        return this;
    }

    public R2 message(String message){
        this.setMessage(message);
        return this;
    }

    public R2 code(Integer code){
        this.setCode(code);
        return this;
    }

    public R2 data(Object data){
        this.data=data;
        return this;
    }

/*    public R2 data(Map<String, Object> map){
        this.setData(map);
        return this;
    }*/


    public Boolean getSuccess() {
        return success;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }


}
